package cn.st4rlight.util.model;

import java.util.Map;

import org.apache.commons.collections4.MapUtils;

import com.google.common.collect.Maps;

import lombok.Data;

/**
 * 或者叫context也可以，本质上就是一个map存取东西
 * @author st4rlight <st4rlight@163.com>
 * Created on 2025-10-18
 */
@Data
public class MetaData {

    // 元数据map，用来存储一些额外的信息
    private Map<String, Object> metaDataMap = Maps.newConcurrentMap();


    public Object getObject(String key) {
        return this.metaDataMap.get(key);
    }

    public void addMetaData(String key, Object value) {
        this.metaDataMap.put(key, value);
    }

    public void addMetaDataMap(Map<String, Object> metaDataMap) {
        if (MapUtils.isNotEmpty(metaDataMap)) {
            this.metaDataMap.putAll(metaDataMap);
        }
    }

    public Object removeMetaData(String key) {
        return metaDataMap.remove(key);
    }
}
